|
|
|
|
|
|
|
Visual Basic is designed to enable developers to create Windows-based applications quickly and easily. This ease-of-use extends to the creation of database programs as well. If you have an existing database that you want to access, Visual Basic makes it easy for you to write a complete data management application with almost no programming. You just drop a few controls on a form and set the properties. In fact, Visual Basic makes the task so easy that it can even create the data entry forms for you. |
|
|
|
|
|
|
|
|
The components that make these capabilities possible are the Data control and data-bound controls. With just these few tools, you can create a wide variety of applications. However, before you get too excited, realize that as you progress to more complex applications, you need to do more of the programming yourself. However, if you are new to Visual Basic, these tools provide a good first step in the database-programming arena and enable you to create application prototypes rapidly. |
|
|
|
|
|
|
|
|
Understanding the Data Control |
|
|
|
|
|
|
|
|
The centerpiece of easy database applications is the Data control. The Data control is one of the controls available in Visual Basic's Toolbox. Setting up the Data control requires only four simple steps: |
|
|
|
|
|
|
|
|
1. Select the Data control from the Toolbox. |
|
|
|
|
|
|
|
|
2. Draw the control on your form. |
|
|
|
|
|
|
|
|
3. Set the DatabaseName property of the control. |
|
|
|
|
|
|
|
|
4. Set the RecordSource property of the control. |
|
|
|
|
|
|
|
|
|
Following these four steps is the minimum required to set up the Data control for use with an Access database. The Jet engine allows you to use several types of databases (they are listed in the Connect property). If you want to access non-Jet databases, such as Microsoft SQL Server, you need to set additional properties.  |
|
|
|
|
|
|
|
|
|
|
A new Data control, the ActiveX Data Control, is discussed in Chapter 28, ''Using ActiveX Data Objects (ADO)." |
|
|
|
|
|
|
|
|
What Is the Data Control? |
|
|
|
|
|
|
|
|
Basically, the Data control is a link between information in your database and the bound controls that you use to display the information. As you set the properties of the Data control, you tell it which database to connect to and what part of that database to access. The Data control makes data from your database available to your program in the form of a recordset. A recordset is just like it sounds, a set of records in the database. By default, the Data control creates a Dynaset-type recordset from one or more of the tables in your database. |
|
|
|
|
|